#ifndef SUBCURVE_H
#define SUBCURVE_H

#include <QWidget>
#include "qcustomplot.h"

//鼠标跟中点
class Tracking
{
public:
    Tracking()
    {
        m_IsDraw=false;
        m_IsMove=false;
        m_IsInit=false;
        m_First=false;
        m_radius=25;
        m_PointCenter=QPoint(0,0);
    }
    ~Tracking(){}
    bool getIsRange(QPoint point)
    {
        if(point.x()>(m_PointCenter.x()-m_radius)&&
                point.x()<(m_PointCenter.x()+m_radius)&&
                point.y()>(m_PointCenter.y()-m_radius)&&
                point.y()<(m_PointCenter.y()+m_radius))
        {
            return true;
        }else{
            return false;
        }
    }
public:
    bool m_IsDraw;
    bool m_IsMove;//鼠标焦点
    bool m_IsInit;
    bool m_First;
    int m_radius;
    QPoint m_PointCenter;//绘制圆心
};
typedef struct _COORDINATEVALUE
{
    double Key;
    double Value;
    _COORDINATEVALUE()
    {
        Key=0;
        Value=0;
    }
}_COORDINATEVALUE;
class SubCurve : public QCustomPlot
{
    Q_OBJECT
public:
    explicit SubCurve(QWidget *parent = nullptr);
    virtual ~SubCurve();    

    QList<_COORDINATEVALUE> m_CoorPoints;

signals:
    void sig_UpdateTrack();//刷新跟踪点数据
protected:
    void drawCursor(QPainter *painter);//绘制跟踪点
    void paintEvent(QPaintEvent *event);
    void mousePressEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void showEvent(QShowEvent *event);//显示事件
    void calculateTrackValue(QPoint Point);

    QPoint m_ClickedPoint;
    Tracking m_Tracking;
};

#endif // SUBCURVE_H
